<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box"></div>
    <div class="box green"></div>
    <div class="box"></div>
    <div class="box inline"></div>
    <div class="box inline green"></div>
    <div class="box inline"></div>
    <div class="box inline green"></div>
    <div class="box inline"></div>
</body>

<style>
    .box {
        height: 50px;
        background: red;
        margin: 10px;
    }

    .inline {
        display: inline-block;
        width: 100px;
    }

    .green {
        background: green;
        max-width: clamp(0px, (100vw - 500px)*1000, 100%);
        max-height: clamp(0px, (100vw - 500px)*1000, 1000px);
        margin: clamp(0px, (100vw - 500px)*1000, 10px);
        overflow: hidden;
    }
</style>

</html>